/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.zrnecko.bowlingnumbers.entity;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import org.jboss.seam.annotations.Name;

/**
 *
 * @author zrnecko
 */
@Entity
@Name("player")
@Table(name="player")
public class Player implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	private String name;
	private int cbaId;

	@OneToOne(fetch=FetchType.EAGER, mappedBy="user")
	private User user;

	@OneToMany(fetch=FetchType.LAZY)
	private Set<Game> games;

	@OneToMany(fetch=FetchType.LAZY)
	private Set<GameBlock> gameBlocks;

	@OneToMany(fetch=FetchType.LAZY)
	private Set<GameSet> gameSets;

	public void setId(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof Player)) {
			return false;
		}
		Player other = (Player) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "net.zrnecko.bowlingnumbers.entity.Player[id=" + id + "]";
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getCbaId() {
		return cbaId;
	}

	public void setCbaId(int cbaId) {
		this.cbaId = cbaId;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Set<Game> getGames() {
		return games;
	}

	public void setGames(Set<Game> games) {
		this.games = games;
	}

	public Set<GameBlock> getGameBlocks() {
		return gameBlocks;
	}

	public void setGameBlocks(Set<GameBlock> gameBlocks) {
		this.gameBlocks = gameBlocks;
	}

	public Set<GameSet> getGameSets() {
		return gameSets;
	}

	public void setGameSets(Set<GameSet> gameSets) {
		this.gameSets = gameSets;
	}

}
